<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <title>GDOU</title>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <style>
        body {
            background-color: #f8f9fa;
        }
        .header {
            background-color: #007bff;
            color: white;
            padding: 20px 0;
            text-align: center;
            border-bottom: 2px solid #0056b3;
            position: relative; /* Added for positioning the logo */
        }
        .header .logo {
            position: absolute; /* Positioning the logo */
            left: 20px; /* Adjust left position */
            top: 10px; /* Adjust top position */
            width: 80px; /* Set logo width larger */
            height: 80px; /* Set logo height to match width */
            border-radius: 50%; /* Make logo circular */
            object-fit: cover; /* Maintain aspect ratio without distortion */
        }
        .welcome-message {
            margin-top: 50px;
            text-align: center;
        }
        .list-group-item {
            transition: background-color 0.3s, color 0.3s;
        }
        .list-group-item a {
            color: #343a40;
            text-decoration: none;
            font-weight: 500;
        }
        .list-group-item:hover {
            background-color: #007bff;
            color: white;
        }
        .logout-btn {
            margin-top: 20px;
            background-color: #dc3545;
            color: white;
            font-weight: bold;
            border-radius: 5px;
            padding: 10px 20px;
            text-align: center;
        }
        .logout-btn:hover {
            background-color: #c82333;
        }
        .footer {
            text-align: center;
            margin-top: 50px;
            padding: 20px 0;
            color: #6c757d;
        }
    </style>
</head>
<body>
<div class="header">
    <img src="GDOU.jpg" alt="校徽" class="logo"> <!-- 添加校徽 -->
    <h1>GDOU C S S</h1>
</div>

<div class="container">
    <div class="welcome-message">
        <h2>欢迎，<span id="usernameDisplay">用户</span>！</h2>
        <p class="lead">请选择您需要的操作：</p>
    </div>

    <ul class="list-group mt-5">
        <li class="list-group-item text-center">
            <a href="course-selection.html" id="courseSelection">选课</a>
        </li>
        <li class="list-group-item text-center">
            <a href="leave-request.html" id="leaveRequest">请假</a>
        </li>
        <li class="list-group-item text-center">
            <a href="#" id="logout" class="logout-btn">退出</a>
        </li>
    </ul>
</div>

<footer class="footer">
    <p>© 2024 GDOU.Suolic 版权所有</p>
</footer>

<script>
    $(document).ready(function () {
        const username = localStorage.getItem('username') || '用户';
        $('#usernameDisplay').text(username);

        // 退出功能
        $('#logout').on('click', function (event) {
            event.preventDefault(); // Prevent the default anchor click behavior
            $.ajax({
                url: 'http://localhost:8088/users/logout',
                type: 'POST',
                success: function () {
                    localStorage.removeItem('userId');
                    alert('成功退出！');
                    window.location.href = '/login.html';
                },
                error: function () {
                    alert('退出失败，请重试！');
                }
            });
        });
    });
</script>
</body>
</html>
